package com.bishe.demo.modules.ticket.dao;

import com.bishe.demo.modules.common.entity.City;
import com.bishe.demo.modules.common.entity.TimeTable;
import com.bishe.demo.modules.ticket.entity.TicketSite;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * @Description TicketSiteDao
 * @Author YHQ
 * @Date 2021/3/30 15:15
 */
@Repository
@Mapper
public interface TicketSiteDao {
    @Select("select * from ticket_site_table WHERE s_m_id = #{sMId}")
    @Results(id = "baseResult",value = {
            @Result(column = "tick_site_id",property = "tickSiteId"),
            @Result(column = "s_m_id",property = "sMId"),
            @Result(column = "fk_city_id",property = "startCity",javaType = City.class,
            one = @One(select = "com.bishe.demo.modules.common.dao.CityDao.getCitiesByFkCityId")),
            @Result(column = "fk_time_id",property = "timeTable",javaType = TimeTable.class,
            one = @One(select = "com.bishe.demo.modules.common.dao.TimeTableDao.getTimeTableByFkTimeId")),
            @Result(column = "ticket_price",property = "ticketPrice"),
            @Result(column = "ticket_num",property = "ticketNum")

    })
    List<TicketSite> getTicketSiteBySmId(Integer sMId);

    @Select("select fk_time_id from ticket_site_table where s_m_id = #{SMId}")
    List<Integer> getFkTimeIdBySMId(Integer sMId);

    @Select("select fk_city_id from ticket_site_table where s_m_id = #{SMId}")
    List<Integer> getFkCityIdBySMId(Integer sMId);









    List<City> getCities();


}
